#include "Feedback.h"

 
//@author A0080451N
bool Feedback::getIsValid(){
	return _isValid;
}
//@author A0080451N
void Feedback::setIsValid(bool result){
	_isValid = result;
}

//@author A0105735J
std::string Feedback:: writeOutExecutionFb(){
	if(_isValid){
		if(succeedType == SucceedAdd){
			_fbCommand = SUCCEED_ADD;
		}else if(succeedType == SucceedDelete){
			_fbCommand = SUCCEED_DEL;
		}else if(succeedType == SucceedUpdate){
			_fbCommand = SUCCEED_UPDATE;
		}else if(succeedType == SuccedRead){
			_fbCommand = SUCCEED_READ;
		}else if(succeedType == SucceedSearch){
			_fbCommand = SUCCEED_SEARCH;
		}else if(succeedType == SucceedMark){
			_fbCommand = SUCCEED_MARK;
		}else if(succeedType == SucceedDisplay){
			_fbCommand = SUCCEED_DISPLAY;
		}else if(succeedType == SucceedStatus){
			_fbCommand = SUCCEED_STATUS;
		}else{ 
			// the last case is SUCCEED_UNDO
			_fbCommand = SUCCEED_UNDO;
		}
	}else{
		if(errorType == ErrorFormat){
			_fbCommand = ERROR_FORMAT;
		}
		else if(errorType == ErrorNotFound){
			_fbCommand = ERROR_NOTFOUND;
		}else if(errorType == ErrorUndo){
			_fbCommand = ERROR_UNDO;
		}else if(errorType == ErrorConfuse){
			_fbCommand = ERROR_CONFUSE;
		}else{
			// the last case is ERROR_ERRORTIME
			_fbCommand = ERROR_ERRORTIME;
		}
	}		
	return _fbCommand;
}
//@author A0080451N
Error Feedback::getErrorType(){
	return errorType;
}
//@author A0080451N
void Feedback::storeUpdateCalendar(std::vector<Event*> e){
	_events = e;
}
//@author A0080451N
std::vector<Event*> Feedback::getUpdateCalendar(){
	return _events;
}


//@author A0105735J
void Feedback::setErrorType(Error type){
	errorType =  type;
}

//@author A0105735J
void Feedback::setSucceedType(Succed type){
	succeedType =  type;
}

//@author A0080451N
std::vector<Event*> Feedback::getEventVector(){
	return _events;
}

//@author A0080451N
std::vector<Event*> Feedback::getEventOnDateClicked(int dayClicked, int monthClicked, int yearClicked){  //get all Timed Events with start time and Deadline events with deadline on date clicked
	std::vector<Event*> eventOnDateClicked;																
	std::vector<Event*>::iterator iter;
	for (iter = _events.begin(); iter != _events.end(); iter++) {
		if((*iter)->isEventOnDateClicked (dayClicked, monthClicked, yearClicked)) 
			eventOnDateClicked.push_back(*iter);
	}
	return eventOnDateClicked;
}